#!/usr/bin/env python
#QuickLog.py
#0.1
import time
import sys

import file_con
import pidgin_interface


def g_and_w():
	
	print "do you wish to overwrite the current quicklog file(if it exists, if it doesnt exist just type y)? y/n"
	first_run = raw_input()

	cdir = file_con.GetRelativeDir()
	filen = "/quicklog"
	
	if first_run == "y":
		
		ifile = open(cdir+filen,"w")

	doc_send = 'Send: the "send" command only works on linux and will send the contents of your\n quicklog file to all pidgin chat windows.'
	doc_quit = "Quit: Exits the Program"


	print 'to exit type "quit"'
	print "\n"
	print "for help type help"


	while 1:
		time.sleep(1)
		
		input = raw_input()
		input += "\n"
		input = input.lower()

		ifile = open(cdir+filen,"a")
		ifile.writelines(input)
		ifile.close()
		
		rfile = open(cdir+filen, "r")
		msg = rfile.read()
		
		if input == "quit\n":
			print "done"
			break
			
		if input == "send\n":
			print msg
			pidgin_interface.send_data(msg)
			
		if input == "help\n":
			print doc_send
			print "\n"
			print doc_quit

		








		


	
	

def main():
	g_and_w()

if __name__ == '__main__': main()
